﻿using Microsoft.Extensions.Caching.Memory;
using StackExchange.Redis;
using StackExchange.Redis.KeyspaceIsolation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSPivot.Common.Cache
{
    /// <summary>
    /// 缓存管理
    /// </summary>
    public static class CacheManager
    {
        private static ICacheService _instance;
        private static readonly object _lock = new object();

        public static void Initialize(CacheConfig config)
        {
            lock (_lock)
            {
                _instance = new CacheService(config);
            }
        }

        public static ICacheService Instance
        {
            get
            {
                if (_instance == null)
                    throw new InvalidOperationException("CacheManager未初始化");
                return _instance;
            }
        }
    }
}
